package com.cheng.im.common.protobuiler;

import com.cheng.im.common.bean.msg.ProtoMsgV1;
import org.springframework.stereotype.Component;

public class MessageReceiveAckBuilder {

    public static ProtoMsgV1.Message build(ProtoMsgV1.Message sourceMsg, String from,
                                           String to, String sdkUuid, long msgId) {
        ProtoMsgV1.Message.Builder builder = sourceMsg.toBuilder();
        builder.setType(ProtoMsgV1.HeadType.MESSAGE_RECEIVE_ACK);
        builder.clearMessageRequest();
        builder.clearMessageGroupRequest();

        ProtoMsgV1.MessageReceiveAck.Builder ackBuilder = ProtoMsgV1.MessageReceiveAck.newBuilder();
        ackBuilder.setFrom(from);
        ackBuilder.setTo(to);
        ackBuilder.setMsgSdkUuid(sdkUuid);
        ackBuilder.setMsgId(msgId);

        builder.setMessageReceiveAck(ackBuilder);

        return builder.build();
    }
}
